Replicated code from Jenny Trickey’s repo here
Summaries generated: 2025 Jun 06 15:12 UTC
Load needed libraries.
# load all libraries
devtools::install_github('taikisan21/PAMpal')
library(PAMpal)
# library(kableExtra) # known bug with R ver 4.3.0 so install from github
devtools::install_github('kupietz/kableExtra')
library(kableExtra)
library(ggplot2)
library(RSQLite)
library(tuneR)
# library(wesanderson)
library(here)
library(DBI)
# I don't think we need these but saving here in case
library(dplyr)
# library(tcltk)
# library(manipulate)
Set user-defined variables.
# name project
# ProjID <- 'MHI UxS Glider Project'
# combine trip, recorder, pg version (all defined in YAML) to single run string
# dbFileStr <- paste0(params$mission, '_', params$drift, '_Kogia_', params$pgver)
# define subfolder paths based on selected analysis folder and trip strings
# path_to_db <- file.path(params$path_pg, 'Database')
# path_to_binaries <- file.path(params$path_pg, 'Binaries', params$drift)
path_to_binaries <- choose.dir(default="", caption = "Select path to specific drift main binaries folder")
# assemble some file names
# pamguard database
# dbFile <- file.path(path_to_db, paste0(dbFileStr, '.sqlite3'))
dbFile <- file.choose()
# dbFile <- choose.files(default = "", caption = "Select database file", multi = FALSE)
# already processed acoustic study 'dets' file
detsFile <- file.path(params$path_dets, paste0(params$mission, '_', params$drift,'/', params$mission, '_2024_', params$drift, '_Filtered.rdata'))
detsFiltFile <- file.path(params$path_dets,
paste0(params$mission, '_', params$drift,'/', params$mission, '_2024_', params$drift, '_', params$channelStr, '.rdata'))
# specify calibration file
# calFile <- params$calFile # pull from YAML
# set path to reference spectra if will be used
path_to_refSpec <- file.path(params$path_to_refSpec) # pull from YAML
# specify which reference spectra to plot
# refSpecList = c('Gm', 'Pc')
refSpecList <- params$refSpecList # pull from YAML
refSpecSp <- params$refSpecSp
# ALTERNATIVE SELECT PATHS
# path_pg <- choose.dir(default = "", caption = "Select path to pamguard folder that contains databases and binaries folders")
# # select path to database files
# path_to_db <- choose.dir(default = "", caption = "Select path to folder with all database files")
# # select path to specific binary drift file
# path_to_binaries <- choose.dir(default="", caption = "Select path to specific drift main folder")
# # set up datebase driver
# sqlite <- dbDriver("SQLite") # outdated/no longer supported
# connect to SQLite database using the newer method
con <- dbConnect(RSQLite::SQLite(), dbname = dbFile)
#Set time zone to UTC
Sys.setenv(TZ = 'UTC')
# reference spectra colors - allows for up to 6 ref specs
# pastel
# rsPalette <- c('#66c2a5', '#fc8d62', '#8da0cb', '#e78ac3',
# '#a6d854', '#ffd92f')
# bold
rsPalette <- c('#1b9e77', '#d95f02', '#7570b3', '#e7298a',
'#66a61e', '#e6ab02')
Source some external functions
source(here::here('_code/functions', 'loadMultiBinaries.R'))
source(here::here('_code/functions', 'plotContours.R'))
source(here::here('_code/functions', 'clickSummary.R'))
source(here::here('_code/functions', 'whistleSummary.R'))
# if not using Rproj/here package use:
# source(file.path(params$path_code, 'R', 'functions', 'loadMultiBinaries.R'))
If already created, load an existing dets PAMpal
AcousticStudy object for event processing. We need to load both the
unfiltered dets and filtered detsFilt
AcousticStudies.
# load existing dets AcousticStudy (created with
# workflow_generate_acousticStudies.R)
# load(detFile)
if (file.exists(detsFile)){
dets <- readRDS(detsFile)
cat('Loaded', detsFile, '\n')
} else {
cat('No AcousticStudy \'dets\' file available', '\n')
}
## Loaded F:/gcp_upload/2_Acoustic-Studies/CalCurCEAS_013/CalCurCEAS_2024_013_Filtered.rdata
if (file.exists(detsFiltFile)){
detsFilt <- readRDS(detsFiltFile)
cat('Loaded', detsFiltFile, '\n')
} else {
cat('No AcousticStudy \'detsFilt\' file available', '\n')
}
## Loaded F:/gcp_upload/2_Acoustic-Studies/CalCurCEAS_013/CalCurCEAS_2024_013_ch1.rdata
# summarize how many events
nEvents <- length(names(PAMpal::events(dets)))
# number of events may change after filtering (all clicks may be filtered out)
nEventsFilt <- length(names(PAMpal::events(detsFilt)))
Loaded F:/gcp_upload/2_Acoustic-Studies/CalCurCEAS_013/CalCurCEAS_2024_013_Filtered.rdata and F:/gcp_upload/2_Acoustic-Studies/CalCurCEAS_013/CalCurCEAS_2024_013_ch1.rdata
## Updated the locations of 1 out of 1 missing database files.
## Updated the locations of 1585 out of 1585 missing binary files.
## Updating files in events...
## | | | 0% | | | 1% | |= | 1% | |= | 2% | |== | 2% | |== | 3% | |=== | 3% | |=== | 4% | |==== | 4% | |==== | 5% | |===== | 6% | |===== | 7% | |====== | 7% | |====== | 8% | |======= | 8% | |======= | 9% | |======== | 9% | |======== | 10% | |========= | 11% | |========= | 12% | |========== | 12% | |========== | 13% | |=========== | 13% | |=========== | 14% | |============ | 14% | |============ | 15% | |============= | 15% | |============= | 16% | |============== | 17% | |============== | 18% | |=============== | 18% | |=============== | 19% | |================ | 19% | |================ | 20% | |================= | 20% | |================= | 21% | |================== | 22% | |================== | 23% | |=================== | 23% | |=================== | 24% | |==================== | 24% | |==================== | 25% | |===================== | 25% | |===================== | 26% | |====================== | 26% | |====================== | 27% | |======================= | 28% | |======================= | 29% | |======================== | 29% | |======================== | 30% | |========================= | 30% | |========================= | 31% | |========================== | 31% | |========================== | 32% | |=========================== | 32% | |=========================== | 33% | |============================ | 34% | |============================ | 35% | |============================= | 35% | |============================= | 36% | |============================== | 36% | |============================== | 37% | |=============================== | 37% | |=============================== | 38% | |================================ | 39% | |================================ | 40% | |================================= | 40% | |================================= | 41% | |================================== | 41% | |================================== | 42% | |=================================== | 42% | |=================================== | 43% | |==================================== | 43% | |==================================== | 44% | |===================================== | 45% | |===================================== | 46% | |====================================== | 46% | |====================================== | 47% | |======================================= | 47% | |======================================= | 48% | |======================================== | 48% | |======================================== | 49% | |========================================= | 49% | |========================================= | 50% | |========================================= | 51% | |========================================== | 51% | |========================================== | 52% | |=========================================== | 52% | |=========================================== | 53% | |============================================ | 53% | |============================================ | 54% | |============================================= | 54% | |============================================= | 55% | |============================================== | 56% | |============================================== | 57% | |=============================================== | 57% | |=============================================== | 58% | |================================================ | 58% | |================================================ | 59% | |================================================= | 59% | |================================================= | 60% | |================================================== | 60% | |================================================== | 61% | |=================================================== | 62% | |=================================================== | 63% | |==================================================== | 63% | |==================================================== | 64% | |===================================================== | 64% | |===================================================== | 65% | |====================================================== | 65% | |====================================================== | 66% | |======================================================= | 67% | |======================================================= | 68% | |======================================================== | 68% | |======================================================== | 69% | |========================================================= | 69% | |========================================================= | 70% | |========================================================== | 70% | |========================================================== | 71% | |=========================================================== | 71% | |=========================================================== | 72% | |============================================================ | 73% | |============================================================ | 74% | |============================================================= | 74% | |============================================================= | 75% | |============================================================== | 75% | |============================================================== | 76% | |=============================================================== | 76% | |=============================================================== | 77% | |================================================================ | 77% | |================================================================ | 78% | |================================================================= | 79% | |================================================================= | 80% | |================================================================== | 80% | |================================================================== | 81% | |=================================================================== | 81% | |=================================================================== | 82% | |==================================================================== | 82% | |==================================================================== | 83% | |===================================================================== | 84% | |===================================================================== | 85% | |====================================================================== | 85% | |====================================================================== | 86% | |======================================================================= | 86% | |======================================================================= | 87% | |======================================================================== | 87% | |======================================================================== | 88% | |========================================================================= | 88% | |========================================================================= | 89% | |========================================================================== | 90% | |========================================================================== | 91% | |=========================================================================== | 91% | |=========================================================================== | 92% | |============================================================================ | 92% | |============================================================================ | 93% | |============================================================================= | 93% | |============================================================================= | 94% | |============================================================================== | 95% | |============================================================================== | 96% | |=============================================================================== | 96% | |=============================================================================== | 97% | |================================================================================ | 97% | |================================================================================ | 98% | |================================================================================= | 98% | |================================================================================= | 99% | |==================================================================================| 99% | |==================================================================================| 100%
## Updated the locations of 1 out of 1 missing database files.
## Updated the locations of 1585 out of 1585 missing binary files.
## Updating files in events...
## | | | 0% | | | 1% | |= | 1% | |= | 2% | |== | 2% | |== | 3% | |=== | 3% | |=== | 4% | |==== | 4% | |==== | 5% | |===== | 6% | |===== | 7% | |====== | 7% | |====== | 8% | |======= | 8% | |======= | 9% | |======== | 9% | |======== | 10% | |========= | 11% | |========= | 12% | |========== | 12% | |========== | 13% | |=========== | 13% | |=========== | 14% | |============ | 14% | |============ | 15% | |============= | 15% | |============= | 16% | |============== | 17% | |============== | 18% | |=============== | 18% | |=============== | 19% | |================ | 19% | |================ | 20% | |================= | 20% | |================= | 21% | |================== | 22% | |================== | 23% | |=================== | 23% | |=================== | 24% | |==================== | 24% | |==================== | 25% | |===================== | 25% | |===================== | 26% | |====================== | 26% | |====================== | 27% | |======================= | 28% | |======================= | 29% | |======================== | 29% | |======================== | 30% | |========================= | 30% | |========================= | 31% | |========================== | 31% | |========================== | 32% | |=========================== | 32% | |=========================== | 33% | |============================ | 34% | |============================ | 35% | |============================= | 35% | |============================= | 36% | |============================== | 36% | |============================== | 37% | |=============================== | 37% | |=============================== | 38% | |================================ | 39% | |================================ | 40% | |================================= | 40% | |================================= | 41% | |================================== | 41% | |================================== | 42% | |=================================== | 42% | |=================================== | 43% | |==================================== | 43% | |==================================== | 44% | |===================================== | 45% | |===================================== | 46% | |====================================== | 46% | |====================================== | 47% | |======================================= | 47% | |======================================= | 48% | |======================================== | 48% | |======================================== | 49% | |========================================= | 49% | |========================================= | 50% | |========================================= | 51% | |========================================== | 51% | |========================================== | 52% | |=========================================== | 52% | |=========================================== | 53% | |============================================ | 53% | |============================================ | 54% | |============================================= | 54% | |============================================= | 55% | |============================================== | 56% | |============================================== | 57% | |=============================================== | 57% | |=============================================== | 58% | |================================================ | 58% | |================================================ | 59% | |================================================= | 59% | |================================================= | 60% | |================================================== | 60% | |================================================== | 61% | |=================================================== | 62% | |=================================================== | 63% | |==================================================== | 63% | |==================================================== | 64% | |===================================================== | 64% | |===================================================== | 65% | |====================================================== | 65% | |====================================================== | 66% | |======================================================= | 67% | |======================================================= | 68% | |======================================================== | 68% | |======================================================== | 69% | |========================================================= | 69% | |========================================================= | 70% | |========================================================== | 70% | |========================================================== | 71% | |=========================================================== | 71% | |=========================================================== | 72% | |============================================================ | 73% | |============================================================ | 74% | |============================================================= | 74% | |============================================================= | 75% | |============================================================== | 75% | |============================================================== | 76% | |=============================================================== | 76% | |=============================================================== | 77% | |================================================================ | 77% | |================================================================ | 78% | |================================================================= | 79% | |================================================================= | 80% | |================================================================== | 80% | |================================================================== | 81% | |=================================================================== | 81% | |=================================================================== | 82% | |==================================================================== | 82% | |==================================================================== | 83% | |===================================================================== | 84% | |===================================================================== | 85% | |====================================================================== | 85% | |====================================================================== | 86% | |======================================================================= | 86% | |======================================================================= | 87% | |======================================================================== | 87% | |======================================================================== | 88% | |========================================================================= | 88% | |========================================================================= | 89% | |========================================================================== | 90% | |========================================================================== | 91% | |=========================================================================== | 91% | |=========================================================================== | 92% | |============================================================================ | 92% | |============================================================================ | 93% | |============================================================================= | 93% | |============================================================================= | 94% | |============================================================================== | 95% | |============================================================================== | 96% | |=============================================================================== | 96% | |=============================================================================== | 97% | |================================================================================ | 97% | |================================================================================ | 98% | |================================================================================= | 98% | |================================================================================= | 99% | |==================================================================================| 99% | |==================================================================================| 100%
Updated file paths to binaries in databases for F:/gcp_upload/2_Acoustic-Studies/CalCurCEAS_013/CalCurCEAS_2024_013_Filtered.rdata and F:/gcp_upload/2_Acoustic-Studies/CalCurCEAS_013/CalCurCEAS_2024_013_ch1.rdata
To be used for manual scoring based on report figures.
# set up output data frame
evTable <- data.frame(drift = character(nEvents), id = character(nEvents),
species = character(nEvents), numClicks = numeric(nEvents))
# populate with drift string and event names
evTable$drift <- paste0(params$mission, '_', params$drift)
evTable$id <- names(PAMpal::events(detsFilt))
# get all click data
allClks <- PAMpal::getClickData(detsFilt)
# get the number of clicks for each event
for (iEvent in c(1:nEventsFilt)){
evTable$numClicks[iEvent] <- length(which(allClks$eventId == evTable$id[iEvent]))
}
# keep only rows/events with at least 200 clicks
evTable <- evTable[which(evTable$numClicks >199),]
# add column for keeping/removing based on median peak frequency
evTable$keep <- FALSE # set all to false, will mark keepers as TRUE in loop
# save event table as CSV
write.csv(evTable, file = file.path(params$path_dets,
paste0('eventTable_', params$mission, '_',
params$drift, '_', Sys.Date(),'.csv')))
493 events (files) in drift. 35 events have at least 200 clicks. Additional events may be removed if the median peak frequency of all high SNR clicks is less than 6 kHz. The final number of events can be found at the very end of the report.
Load the reference spectra for plotting, if set with
refSpecList.
# refSpecList is specified in YAML params. Can be one or multiple species
# for single species specify as char string without quotations e.g., refSpecPc
# for multiple species, specify with call to R and c()
# e.g., !r c('meanSpecGm', 'refSpecPc_LLHARP')
refSpecs <- NULL
if (!is.null(refSpecList)){
refSpecs = list()
for (rs in refSpecList){
refSpecs[[rs]] = read.csv(file.path(path_to_refSpec, paste0(rs, '.csv')))
}
}
Loop through each detection event (n = 35) create plots and a table of summary statistics for click and whistle detections. This process uses AcousticStudy objects that have detection data for each event, and also pulls information from the Pamguard binaries associated with each AcousticStudy.
Click plots (other than the SNR plot) only show clicks with SNRs >= 15 dB.
for (iEvent in c(1:nEventsFilt)){
# iEvent = 6 # for testing
# ("pagebreak \n")
# extract this event UID string
eventList <- PAMpal::events(detsFilt)
eventUID <- names(eventList)[iEvent]
###### summarize clicks ######
cl <- clickSummary(detsFilt, eventUID)
if ((cl$nClicks > 199) && median(cl$goodClicks$peak, na.rm = TRUE) >= 6){
# keep this in evTable
evTable$keep[evTable$id == eventUID] <- TRUE
evTable$medPeakFrq[evTable$id == eventUID] <- median(cl$goodClicks$peak,
na.rm = TRUE)
# set header for this event and print time
cat('\n\n#### Event ID: ', names(eventList)[iEvent], '\n')
cat('Time: ', format(eventList[[eventUID]]@ancillary$grouping$start,
'%Y-%m-%d %H:%M%Z'), ' to ',
format(eventList[[eventUID]]@ancillary$grouping$end, '%Y-%m-%d %H:%M%Z'),
'\n')
cat('\nEvent contains', nrow(PAMpal::getClickData(dets[[eventUID]])),
'original clicks,', paste0('**', cl$nClicks), 'valid clicks** after',
'filtering.\n')
cat('\n')
###### summarize whistles ######
# wl <- whistleSummary(detsFilt, eventUID)
#
# cat('\nEvent contains', paste0('**', wl$nWhistles), 'whistles**.\n')
# cat('\n')
###### click plots and table ######
cat('\n##### Click plots and table\n')
cat('\n SNR histogram includes all filtered clicks. Other plots contain only',
'clicks with SNR >= 15 dB', paste0('(**n = ', cl$nGoodClicks, ' clicks**)'),
'.\n')
cat('\n')
# if any clicks...
if (cl$nClicks > 0){
# histogram of all clicks and SNR >= 15 dB cut off
xMax <- max(c(15, ceiling(max(cl$snr)) + 2)) # whichever is bigger
if (any(!is.na(cl$snr))){
hist(cl$snr, breaks = seq(from = floor(min(cl$snr)),
to = xMax, by = 2),
main = 'Click SNR', sub = '(all filtered clicks)', xlab = 'SNR')
abline(v = 15, lty = 2, lwd = 2, col = 'red4')
}
}
# if sufficient good clicks...
if (cl$nGoodClicks > 0) {
# histogram of click durations - good clicks only
subStr <- paste0('(high SNR clicks, n=', cl$nGoodClicks, ')')
hist(cl$goodClicks$duration,
breaks = seq(from = 0, to = max(cl$goodClicks$duration) + 100,
by = 100), main = 'Click duration', sub = subStr,
xlab = expression(paste('duration [', mu, 's]')))
abline(v = median(cl$goodClicks$duration), lty = 2, lwd = 2, col = 'black')
legend('topright', legend = 'median', lty = 2, lwd = 2, col = 'black')
cat('\n')
cat('\n')
# Calculate and plot Concatenated and Mean Spectrum for clicks w/ max SNR > 15dB
# NB: JLKM uses more exaggerated SNR (>40 dB) for BWs bc actual spectra may
# be noisy for single clicks
# reducing wl can give more accurate noise floor but 'smoother' spectrum
# increasing wl will give more exact spectrum but may exclude too many
# clicks based on SNR (noise measure will overlap with click output; noise
# is just measured as same wl from start of binary snippet and binaries
# binary snippets are v short)
# Trial and error - 256 works ok for LLHARP data = 1.28 ms
# NB: JLKM uses 500 for beaked whales with samp rate 288k
avgSpec <- PAMpal::calculateAverageSpectra(detsFilt, evNum = eventUID, wl = 256,
channel = params$channelNum, norm = TRUE,
noise = TRUE, sort = TRUE, snr = 15,
plot = c(TRUE, FALSE))
# concatenated spectrogram will get plotted within calculation
# avg spectrum plots separately (bc adding stuff)
if (!is.null(avgSpec)) {
# Peak freq as calculated by calculateAvgerageSpectra -for subtitle
peakFreq <- round(avgSpec$freq[which.max(avgSpec$avgSpec)]/1000, 2)
plot(1, type = 'n', xlim = c(0, 100), ylim = c(min(avgSpec$avgSpec), 0),
xlab = 'Frequency (kHz)', ylab = 'Normalized Magnitude (dB)',
main = 'Average Spectrum', sub = paste0('Peak: ', peakFreq, 'kHz'))
# add grid lines for frequency at 10 kHz intervals
for (iline in ((0:20)*10)) {lines(c(iline,iline), c(-100,10), col="gray")}
# add template spectra
if (length(refSpecs) > 0){
rsCols <- rsPalette[1:length(refSpecs)]
for (rs in 1:length(refSpecs)){
rsTmp <- refSpecList[rs]
rsNorm <- refSpecs[[rsTmp]]
rsMax <- max(rsNorm$dB)
rsNorm$dBNorm <- rsNorm$dB - rsMax
lines(rsNorm$frq, rsNorm$dBNorm, col = rsCols[rs], lwd = 2)
}
}
# plot noise
lines(avgSpec$freq/1000, avgSpec$avgNoise, lty = 3, lwd = 2)
# plot avg spectrum
lines(avgSpec$freq/1000, avgSpec$avgSpec, lty = 2, lwd = 3)
# also plot median spectrum
medSpec <- 20*log10(apply(avgSpec$allSpec, 1, function(y) {
median(10^(y/20), na.rm = TRUE)}))
medSpecNorm <- medSpec - max(medSpec, na.rm = TRUE)
lines(avgSpec$freq/1000, medSpecNorm, lty = 1, lwd = 3)
# add legend
if (length(refSpecs) > 0){
legend(x = 'topright', c(refSpecSp, 'Avg.', 'Med.', 'Noise'),
lty = c(rep(1, length(refSpecs)), 2, 1, 3),
lwd = c(rep(1, length(refSpecs)), 2, 3, 2),
col = c(rsCols, 'black', 'black', 'black'), cex = 0.8)
} else if (length(refSpecs) == 0){
legend(x = 'topright', c('Avg.', 'Med.', 'Noise'),
lty = c(2, 1, 3), lwd = c(2, 3, 2),
col = c('black', 'black', 'black'), cex = 0.8)
}
}
# NB: JLKM BW approach has additional plots here:
# IPI
# Waveform of strongest click
# Wigner plot
# We are not including those here because not really useful for FKW, but if
# interested in adding back in, see:
# https://github.com/jlkeating/PAMGuard_Event_Code
cat('\n')
cat('\n')
# create median stats table for clicks with -15 dB TK noise cut off
cat('\n\n Median statistics for', cl$nGoodClicks, 'high SNR clicks with',
'SNR >= 15 dB.')
cat('\n')
cat(knitr::kable(cl$mt, format = 'html', caption = '', align = 'l',
row.names = FALSE) %>%
kableExtra::kable_styling(bootstrap_options = c('basic', 'condensed'),
full_width = F))
} else { # no good clicks so no summary plots/table
cat('\nNo clicks of sufficient SNR to plot or summarize.\n')
}
###### whistle plots and table ######
#
# cat('\n##### Whistle plots and table\n')
#
# # if whistles present ...
# if (wl$nWhistles > 0) {
# # create median stats table for all whistles
# # cat('\n\n Median statistics for', wl$nWhistles, 'whistles.')
# # cat('\n')
#
# # plot whistle contours
# # map the needed binary files
# binFiles <- dets@events[[eventUID]]@files$binaries
# wmFileIdx <- grep(pattern = '^.*WhistlesMoans_Whistle_and_Moan.*\\.pgdf$',
# binFiles)
# wmFiles <- dets@events[[eventUID]]@files$binaries[wmFileIdx]
#
# # load them
# whBin <- loadMultiBinaries(wmFiles)
# # trim to just the event time
# whBinEv <- whBin[names(whBin) %in%
# detsFilt[[eventUID]]$Whistle_and_Moan_Detector$UID]
#
# # #plot - ggplot version/functionized
# # pc <- plotContours(whBinEv)
# # # print(pc)
# # pc + ggtitle(eventUID)
# #
#
# # get plot limits
# # xMax <- 0
# # yMax <- 0
# # for (wc in 1:length(names(whBinEv))){
# # df <- data.frame(time = whBinEv[[wc]]$time - whBinEv[[wc]]$time[1],
# # freq = whBinEv[[wc]]$freq/1000)
# # xMaxTmp <- max(df$time)
# # yMaxTmp <- max(df$freq)
# # if (xMaxTmp > xMax){xMax <- xMaxTmp}
# # if (yMaxTmp > yMax){yMax <- yMaxTmp}
# # }
# # or use standard max lims
# xMax <- 1.5
# yMax <- 20
#
# # plot each line
# plot(1, type = 'n', xlim = c(0, round(xMax,2)), ylim = c(0, round(yMax,-1)),
# xlab = 'Time (s)', ylab = 'Frequency (kHz)',
# main = 'Whistle Contours')
# # add grid lines for frequency at 0.125 s and 5 kHz intervals
# for (iline in (seq(0,2,0.125))) {lines(c(iline,iline), c(-10,60),
# col="lightgray")}
# for (iline in (seq(0,50,5))) {lines(c(-0.5,2.5), c(iline,iline),
# col="lightgray")}
# # loop through each contour
# for (wc in 1:length(names(whBinEv))){
# df <- data.frame(time = whBinEv[[wc]]$time - whBinEv[[wc]]$time[1],
# freq = whBinEv[[wc]]$freq/1000)
# lines(df$time, df$freq, col = rgb(0,0,0,0.4))
# }
#
# # plot histogram of median frequency
# hist(wl$wh$freqMedian/1000,
# breaks = seq(0, ceiling(max(wl$wh$freqMedian/1000)) + 1, 1),
# main = 'Histogram of whistle median frequency',
# xlab = 'Median frequency (kHz)')
#
# cat('\n')
# cat('\n')
#
# cat('Median statistics for n = ', wl$nWhistles, 'whistles.\n')
# # create median stats table for all whistles
# cat(knitr::kable(wl$mt, format = 'html', caption = '', align = 'l',
# row.names = FALSE) %>%
# kable_styling(bootstrap_options = c('basic', 'condensed'),
# full_width = F))
#
# } else {
# cat('\nNo whistles present.\n')
# }
cat('\n')
cat('\n\n --- \n\n')
cat('\n')
}# num clicks/peak freq check
} # loop
Time: 2024-10-03 02:42UTC to 2024-10-03 02:48UTC
Event contains 490 original clicks, 245 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 42 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 24.6 |
| Median 3dB Center Frequency [kHz] | 20.4 |
| Median 10dB Center Frequency [kHz] | 19.9 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.24 (19.5 - 21.7) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 3.7 ( 17 - 22.8) |
| Median duration [μs] (25-75 percentile) | 63 (20 - 288) |
Time: 2024-10-03 02:48UTC to 2024-10-03 02:54UTC
Event contains 418 original clicks, 209 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 23 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 21.2 |
| Median 3dB Center Frequency [kHz] | 5.98 |
| Median 10dB Center Frequency [kHz] | 5.79 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.33 (5.74 - 6.22) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 2.38 (4.88 - 6.69) |
| Median duration [μs] (25-75 percentile) | 55 (27 - 331) |
Time: 2024-10-03 04:42UTC to 2024-10-03 04:47UTC
Event contains 706 original clicks, 353 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 228 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 6.6 |
| Median 3dB Center Frequency [kHz] | 6.2 |
| Median 10dB Center Frequency [kHz] | 6.77 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.48 (5.48 - 6.93) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 4.49 (4.17 - 9.18) |
| Median duration [μs] (25-75 percentile) | 180 (0 - 1124) |
Time: 2024-10-03 15:12UTC to 2024-10-03 15:18UTC
Event contains 864 original clicks, 432 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 385 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 7.2 |
| Median 3dB Center Frequency [kHz] | 7.01 |
| Median 10dB Center Frequency [kHz] | 7.23 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.29 (6.36 - 7.75) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 3.4 ( 5.4 - 9.06) |
| Median duration [μs] (25-75 percentile) | 258 (0 - 1000) |
Time: 2024-10-03 15:18UTC to 2024-10-03 15:23UTC
Event contains 682 original clicks, 341 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 303 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 7.6 |
| Median 3dB Center Frequency [kHz] | 7.31 |
| Median 10dB Center Frequency [kHz] | 7.37 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.26 (6.62 - 8.04) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 3.49 (5.44 - 9.25) |
| Median duration [μs] (25-75 percentile) | 26 (0 - 282) |
Time: 2024-10-03 15:24UTC to 2024-10-03 15:30UTC
Event contains 718 original clicks, 359 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 300 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 7.6 |
| Median 3dB Center Frequency [kHz] | 7.29 |
| Median 10dB Center Frequency [kHz] | 7.23 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.1 (6.48 - 7.85) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 3.32 (5.23 - 8.98) |
| Median duration [μs] (25-75 percentile) | 0 (0 - 373) |
Time: 2024-10-03 15:30UTC to 2024-10-03 15:36UTC
Event contains 744 original clicks, 372 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 284 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 6 |
| Median 3dB Center Frequency [kHz] | 5.74 |
| Median 10dB Center Frequency [kHz] | 5.85 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.04 (5.07 - 6.31) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 2.97 (4.08 - 7.57) |
| Median duration [μs] (25-75 percentile) | 0 (0 - 185) |
Time: 2024-10-03 15:36UTC to 2024-10-03 15:42UTC
Event contains 802 original clicks, 401 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 301 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 6.4 |
| Median 3dB Center Frequency [kHz] | 6.21 |
| Median 10dB Center Frequency [kHz] | 6.4 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 0.978 (5.69 - 6.85) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 2.8 (4.39 - 8.12) |
| Median duration [μs] (25-75 percentile) | 0 (0 - 321) |
Time: 2024-10-03 15:42UTC to 2024-10-03 15:47UTC
Event contains 530 original clicks, 265 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 189 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 6 |
| Median 3dB Center Frequency [kHz] | 5.8 |
| Median 10dB Center Frequency [kHz] | 5.73 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.06 (5.25 - 6.25) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 3.21 ( 4 - 7.54) |
| Median duration [μs] (25-75 percentile) | 0 (0 - 1000) |
Time: 2024-10-03 16:00UTC to 2024-10-03 16:05UTC
Event contains 798 original clicks, 399 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 291 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 7.2 |
| Median 3dB Center Frequency [kHz] | 7.04 |
| Median 10dB Center Frequency [kHz] | 7.1 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.04 (6.43 - 7.66) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 2.66 (5.49 - 8.63) |
| Median duration [μs] (25-75 percentile) | 0 (0 - 3) |
Time: 2024-10-03 16:06UTC to 2024-10-03 16:12UTC
Event contains 778 original clicks, 389 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 265 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 7.2 |
| Median 3dB Center Frequency [kHz] | 6.9 |
| Median 10dB Center Frequency [kHz] | 6.84 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.1 (6.31 - 7.41) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 3.2 (4.73 - 8.93) |
| Median duration [μs] (25-75 percentile) | 0 (0 - 23) |
Time: 2024-10-03 16:12UTC to 2024-10-03 16:18UTC
Event contains 968 original clicks, 484 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 389 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 6.8 |
| Median 3dB Center Frequency [kHz] | 6.63 |
| Median 10dB Center Frequency [kHz] | 6.93 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.03 (6.06 - 7.53) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 3.27 (4.89 - 8.86) |
| Median duration [μs] (25-75 percentile) | 0 (0 - 1000) |
Time: 2024-10-03 16:18UTC to 2024-10-03 16:24UTC
Event contains 1380 original clicks, 690 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 636 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 6.8 |
| Median 3dB Center Frequency [kHz] | 6.64 |
| Median 10dB Center Frequency [kHz] | 6.97 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.24 (5.93 - 7.58) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 3.86 (4.56 - 9.05) |
| Median duration [μs] (25-75 percentile) | 644 (0 - 1376) |
Time: 2024-10-03 16:24UTC to 2024-10-03 16:29UTC
Event contains 1386 original clicks, 693 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 630 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 7.2 |
| Median 3dB Center Frequency [kHz] | 7.23 |
| Median 10dB Center Frequency [kHz] | 7.24 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.03 (6.72 - 7.73) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 3.14 (5.39 - 8.89) |
| Median duration [μs] (25-75 percentile) | 26 (0 - 1000) |
Time: 2024-10-03 16:30UTC to 2024-10-03 16:36UTC
Event contains 1398 original clicks, 699 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 555 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 7.6 |
| Median 3dB Center Frequency [kHz] | 7.24 |
| Median 10dB Center Frequency [kHz] | 7.27 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1 (6.56 - 7.77) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 3.2 (5.25 - 8.76) |
| Median duration [μs] (25-75 percentile) | 0 (0 - 100) |
Time: 2024-10-03 16:36UTC to 2024-10-03 16:42UTC
Event contains 772 original clicks, 386 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 315 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 6.8 |
| Median 3dB Center Frequency [kHz] | 6.85 |
| Median 10dB Center Frequency [kHz] | 6.79 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.07 (6.24 - 7.43) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 3.39 (4.87 - 8.58) |
| Median duration [μs] (25-75 percentile) | 0 (0 - 17) |
Time: 2024-10-03 16:54UTC to 2024-10-03 16:59UTC
Event contains 942 original clicks, 471 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 391 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 6.8 |
| Median 3dB Center Frequency [kHz] | 6.67 |
| Median 10dB Center Frequency [kHz] | 6.62 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.27 (5.85 - 7.46) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 3.6 (4.45 - 8.7) |
| Median duration [μs] (25-75 percentile) | 172 (0 - 1000) |
Time: 2024-10-03 17:00UTC to 2024-10-03 17:06UTC
Event contains 1992 original clicks, 996 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 739 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 7.2 |
| Median 3dB Center Frequency [kHz] | 7.11 |
| Median 10dB Center Frequency [kHz] | 7.04 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.32 (6.28 - 7.82) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 3.86 (4.75 - 9.25) |
| Median duration [μs] (25-75 percentile) | 29 (0 - 309) |
Time: 2024-10-03 17:06UTC to 2024-10-03 17:12UTC
Event contains 1650 original clicks, 825 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 625 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 7.6 |
| Median 3dB Center Frequency [kHz] | 7.68 |
| Median 10dB Center Frequency [kHz] | 7.42 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.42 (6.68 - 8.55) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 3.95 (5.29 - 9.75) |
| Median duration [μs] (25-75 percentile) | 55 (0 - 451) |
Time: 2024-10-03 17:12UTC to 2024-10-03 17:17UTC
Event contains 1810 original clicks, 905 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 642 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 7.2 |
| Median 3dB Center Frequency [kHz] | 7.1 |
| Median 10dB Center Frequency [kHz] | 6.92 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.32 (6.39 - 7.87) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 4.02 (4.59 - 9.27) |
| Median duration [μs] (25-75 percentile) | 17 (0 - 370) |
Time: 2024-10-03 17:18UTC to 2024-10-03 17:24UTC
Event contains 2420 original clicks, 1210 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 914 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 7.6 |
| Median 3dB Center Frequency [kHz] | 7.46 |
| Median 10dB Center Frequency [kHz] | 7.32 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.56 (6.43 - 8.33) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 4.89 (4.59 - 9.81) |
| Median duration [μs] (25-75 percentile) | 293 (13 - 1000) |
Time: 2024-10-03 17:24UTC to 2024-10-03 17:30UTC
Event contains 3332 original clicks, 1666 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 1268 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 7.2 |
| Median 3dB Center Frequency [kHz] | 7 |
| Median 10dB Center Frequency [kHz] | 7.03 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.32 (6.12 - 7.9) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 3.97 (4.62 - 9.17) |
| Median duration [μs] (25-75 percentile) | 130 (0 - 447) |
Time: 2024-10-03 17:30UTC to 2024-10-03 17:35UTC
Event contains 1536 original clicks, 768 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 540 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 7.6 |
| Median 3dB Center Frequency [kHz] | 7.75 |
| Median 10dB Center Frequency [kHz] | 7.88 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.24 (6.88 - 8.59) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 3.64 (5.95 - 9.68) |
| Median duration [μs] (25-75 percentile) | 0 (0 - 146) |
Time: 2024-10-03 17:36UTC to 2024-10-03 17:42UTC
Event contains 1670 original clicks, 835 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 553 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 7.6 |
| Median 3dB Center Frequency [kHz] | 7.44 |
| Median 10dB Center Frequency [kHz] | 7.53 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.17 (6.78 - 8.03) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 3.36 (5.65 - 9.36) |
| Median duration [μs] (25-75 percentile) | 0 (0 - 29) |
Time: 2024-10-03 17:42UTC to 2024-10-03 17:47UTC
Event contains 1138 original clicks, 569 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 388 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 6.8 |
| Median 3dB Center Frequency [kHz] | 6.71 |
| Median 10dB Center Frequency [kHz] | 6.93 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.4 (5.91 - 7.37) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 3.97 (4.32 - 9.35) |
| Median duration [μs] (25-75 percentile) | 265 (0 - 1000) |
Time: 2024-10-03 18:00UTC to 2024-10-03 18:05UTC
Event contains 682 original clicks, 341 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 279 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 6.8 |
| Median 3dB Center Frequency [kHz] | 6.66 |
| Median 10dB Center Frequency [kHz] | 6.6 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.21 (6.04 - 7.39) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 3.44 (4.89 - 8.3) |
| Median duration [μs] (25-75 percentile) | 42 (0 - 1000) |
Time: 2024-10-03 19:06UTC to 2024-10-03 19:12UTC
Event contains 424 original clicks, 212 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 147 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 6 |
| Median 3dB Center Frequency [kHz] | 5.84 |
| Median 10dB Center Frequency [kHz] | 6.04 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.15 (5.05 - 6.54) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 3.04 (4.31 - 7.58) |
| Median duration [μs] (25-75 percentile) | 52 (0 - 417) |
Time: 2024-10-03 19:18UTC to 2024-10-03 19:24UTC
Event contains 512 original clicks, 256 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 129 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 6.4 |
| Median 3dB Center Frequency [kHz] | 6.43 |
| Median 10dB Center Frequency [kHz] | 6.36 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.08 (5.83 - 6.87) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 3.26 ( 4.5 - 7.66) |
| Median duration [μs] (25-75 percentile) | 0 (0 - 112) |
Time: 2024-10-04 03:48UTC to 2024-10-04 03:54UTC
Event contains 456 original clicks, 228 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 112 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 7.2 |
| Median 3dB Center Frequency [kHz] | 6.82 |
| Median 10dB Center Frequency [kHz] | 6.88 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.4 (5.98 - 7.51) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 4.29 (4.43 - 9.17) |
| Median duration [μs] (25-75 percentile) | 176 (100 - 1000) |
Time: 2024-10-04 03:54UTC to 2024-10-04 04:00UTC
Event contains 1852 original clicks, 926 valid clicks after filtering.
SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 475 clicks) .
| parameter | value |
|---|---|
| Median Peak Frequency [kHz] | 7.2 |
| Median 3dB Center Frequency [kHz] | 7.15 |
| Median 10dB Center Frequency [kHz] | 7.5 |
| Median 3dB Bandwidth [kHz] (lower-upper) | 1.22 ( 6.4 - 7.74) |
| Median 10dB Bandwidth [kHz] (lower-upper) | 4.44 (4.84 - 9.89) |
| Median duration [μs] (25-75 percentile) | 342 (102 - 1000) |
# clean up the event table
evTable <- evTable[evTable$keep == TRUE,]
evTable <- subset(evTable, select = -keep)
# save event table as CSV
write.csv(evTable, file = file.path(params$path_dets,
paste0('eventTable_', params$mission, '_',
params$drift, '_', Sys.Date(),'.csv')))
#dbDisconnect(dbFile)
After additional filtering based on median peak frequency, 30 events events of 493 original events remain.